package tag19_05_08.wdh;


class Tier {
	static final int MAX_ALTER = 200;
}

class Hund extends Tier {
	static final int MIN_ALTER = 0; 
}

public class CastReferenzen {

	public static void main(String[] args) {

		Comparable cmp = "hello";
		
		Object obj = "hello";
		
		System.out.println( cmp == obj ); //true
		
//		int erg = obj.compareTo("HELLO");
//
//		obj = new Hund();
//		erg = obj.compareTo("HELLO");
		
		cmp = (Comparable)obj;
		int erg = cmp.compareTo("HELLO");
		
		erg = ((Comparable)obj).compareTo("HELLO");
		erg = ((String)obj).compareTo("HELLO");
		
		String str = "hello";
		//Hund h1 = (Hund)str; //Compilerfehler!
		
		System.out.println("----------------------------------");
		
		System.out.println( Tier.MAX_ALTER ); //200
		System.out.println( Hund.MIN_ALTER); //0
		
		Hund h2 = new Hund();
		System.out.println( h2.MIN_ALTER ); //Warnung ist kompilierbar:
		//Der Compiler ersetzt die Variable 'h2' durch den Klassennamen 'Hund'
		
		System.out.println( h2.toString() );

		h2 = null;
//		System.out.println( h2.toString() ); //NullPointerException
		
		System.out.println( h2.MIN_ALTER ); //0
		
	} //end of main

}
